use proto_bytes::frame::ToEc;
use utils::ufmt;

use crate::error::AppErr;


pub mod handler;
pub mod status;
mod driver;


#[derive(ufmt::derive::uDebug, Clone, Copy)]
pub enum CargoErr {
    PickAlm = 0x11,
    PickTimeout = 0x12,

    CargoAlm = 0x13,
    CargoTimeout = 0x14,

    ScanTimeout = 0x15,
    ScanInvalid = 0x16,

    CyTopFail = 0x17,
    CyBottomFail = 0x18,
    CyInnerFail = 0x19,
    CyExternFail = 0x1A,

    PickFail = 0x1B,
}

impl From<CargoErr> for AppErr {
    fn from(value: CargoErr) -> Self {
        Self::Cargo(value)
    }
}

impl ToEc for CargoErr {
    fn to_ec(self) -> u8 {
        self as u8
    }
}

pub unsafe fn init() {
    driver::init();
}
